package com.example.administrator.yuejian23.Activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.administrator.yuejian23.Bean.ClubVideo;
import com.example.administrator.yuejian23.Fragment.ClubCourseFragment;
import com.example.administrator.yuejian23.Fragment.ClubIntroFragment;
import com.example.administrator.yuejian23.Fragment.ClubVideoFragment;
import com.example.administrator.yuejian23.R;
import com.squareup.picasso.Picasso;

/**
 * Created by Administrator on 2017/11/13.
 */

public class ClubInfoActivity extends AppCompatActivity {
    private ImageView imageView;
    private RadioGroup radioGroup;
    private ClubCourseFragment clubCourseFragment;
    private ClubIntroFragment clubIntroFragment;
    private ClubVideoFragment clubVideoFragment;
    private FragmentManager manager;
    private FragmentTransaction transaction;

    private TextView Club_Name;
    private ImageView Club_Pic;
    private String Club_Name_xml;
    private String Club_Name_Pic;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_club_info);

        Club_Name_Pic=getIntent().getStringExtra("Club_Pic");
        Club_Name_xml=getIntent().getStringExtra("Club_Name");
        imageView= (ImageView)findViewById(R.id.imageView4);
        radioGroup= (RadioGroup)findViewById(R.id.radioGroup);
        Club_Name= (TextView) findViewById(R.id.club_radio_name);
        Club_Name.setText(Club_Name_xml);
        Club_Pic= (ImageView) findViewById(R.id.club_radio_pic);
        Picasso.with(ClubInfoActivity.this)
                .load(Club_Name_Pic)
                .into(Club_Pic);
        //
        manager=getSupportFragmentManager();
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {

                switch (checkedId){

                    case R.id.radio_club_info:
                        clubIntroFragment=new ClubIntroFragment();
                        replace(clubIntroFragment);
                        break;
                    case R.id.radio_club_course:
                        clubCourseFragment=new ClubCourseFragment();
                        replace(clubCourseFragment);
                        break;
                    case R.id.radio_club_video:
                        clubVideoFragment=new ClubVideoFragment();
                        replace(clubVideoFragment);
                        break;
                }
            }
        });

        radioGroup.check(R.id.radio_club_info);

    }

    private void replace(Fragment fragment){
        transaction=manager.beginTransaction();
        transaction.replace(R.id.clubinfo_framelayout,fragment);
        transaction.commit();
    }
}
